var textarea
function copyText(text) { //复制功能函数
    if (!textarea) {
        textarea = document.createElement('textarea')
    }
    textarea.style.position = 'fixed'
    textarea.style.left = '-500px'
    textarea.style.top = '500px'
    textarea.textContent = text.replace(/[\u00A0]/gi, " "),
        // input.setAttribute('value', text)
        document.body.appendChild(textarea)
    textarea.select()
    document.execCommand('Copy')
    document.body.removeChild(textarea)
}


setTimeout(function () {
    var style = document.createElement('style');
    // 使点击按钮后不会出现登陆框，以及代码可以选中
    style.innerHTML = `.passport-login-container { 
                        display: none!important 
                    } 
            #content_views pre, #content_views pre code {
                -webkit-touch-callout: unset!important;;
                -webkit-user-select: unset!important;;
                -khtml-user-select: unset!important;;
                -moz-user-select: unset!important;;
                -ms-user-select: unset!important;;
                user-select: unset!important;;
            }`;
    document.head.appendChild(style);
}, 10);


 setTimeout(() => { 
    var lists = document.getElementsByClassName('hljs-button'); 
    for (var i = 0, len = lists.length; i < len; i++) {
        var element = lists[i]
        element.setAttribute('data-title', '复制'); // 将登陆复制按钮修改成复制按钮
        element.onclick = (e) => { // 点击复制按钮实现代码复制
            var i = e.target || e.srcElement; 
            var text = i.parentNode.innerText.replace(/[\u00A0]/gi, " ");
            copyText(text)
        }
    }
    document.getElementById('content_views').oncopy = function (event) { // 实现选中文字可复制
        var selection = document.getSelection();
        var selectContent = selection.toString();
        copyText(selectContent)
    }
}, 100)